﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WinnerCMS.Data.Mapping
{
    public partial class UserAddressMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<WinnerCMS.Model.UserAddress>
    {
        public UserAddressMap()
        {
            // table
            //ToTable("CMS_UserAddresses");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.UserId)
                
                .IsRequired();
            Property(t => t.NickName)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.Email)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.Address)
                
                .HasMaxLength(200)
                .IsOptional();
            Property(t => t.PostCode)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.Tel)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.Moblie)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.Flag)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.BestTime)
                
                .HasMaxLength(100)
                .IsOptional();
            Property(t => t.IsDefault)
                
                .IsRequired();

            // Relationships
            HasRequired(t => t.User)
                .WithMany(t => t.UserAddresses)
                .HasForeignKey(d => d.UserId);

            //InitializeMapping();
        }
    }
}

